package com.tcfvic.server;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.tcfvic.server.persistance.HibernateUtil;

public class TestHelper {

	/**
	 * @param args
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Session session = HibernateUtil.getSession();

		session.beginTransaction();
		Query crit = session
				.createQuery("select ed.id.personId, p.firstname, p.surname, wc.name from "
						+ "Person p left outer join p.employmentdetailses ed "
						+ "left outer join ed.workercompany wc" + "");
		crit.setFirstResult(0);
		crit.setMaxResults(10);
		List<Object> result = crit.list();
		System.out.println(result.size());
		for (int i = 0; i < result.size(); i++) {
			Object[] line = (Object[]) result.get(i);

			System.out.println(line[0] + " " + line[1] + " " + line[2] + " "
					+ line[3]);
		}
		// personDetails.addAll(crit.list());
		session.getTransaction().commit();

	}

}
